<template>
  <div class="ProductionHmPg">
    <div class="Prod_left">
      <div class="left_Up">
        <div class="left_left">
          <p class="Headline">上月总工资</p>
          <div class="tp2">元</div>
          <div class="dd1">
            <span class="sp11">00.00</span>
          </div>
          <div class="tp2s">
            <div class="ll1">
              <div class="d1">00.00</div>
              <div>总绩效</div>
            </div>
            <div class="ll1">
              <div class="d1">00.00</div>
              <div>总基本工资</div>
            </div>
            <div class="ll1 rr1">
              <div class="d1">00.00</div>
              <div>考勤扣款</div>
            </div>
          </div>
        </div>
        <div class="left_right">
          <p class="Headline">上月月考勤统计</p>
          <div class="progress">
            <p class="progresscq">出勤情况</p>
            <div class="pro">
              <el-progress :text-inside="true" :stroke-width="24" :percentage="100"></el-progress>
            </div>
            <p class="progresspeople">50人</p>
          </div>
          <div class="progress">
            <p class="progresscq">迟到情况</p>
            <div class="pro">
              <el-progress :text-inside="true" :stroke-width="24" :percentage="30" status="success"></el-progress>
            </div>
            <p class="progresspeople">10人</p>
          </div>
          <div class="progress">
            <p class="progresscq">缺勤情况</p>
            <div class="pro">
              <el-progress :text-inside="true" :stroke-width="24" :percentage="10" status="warning"></el-progress>
            </div>
            <p class="progresspeople">3人</p>
          </div>
        </div>
      </div>
      <div class="left_down">
        <p class="Headline">本月生产计划</p>
        <div class="list">
          <el-table :data="tableDataonmonth" stripe>
            <el-table-column prop type="index" label="序号" width="70px" align="center"></el-table-column>
            <el-table-column prop label="产品图片" align="center">
              <template slot-scope="scope">
                <img :src="scope.row.matpic2" alt />
              </template>
            </el-table-column>
            <el-table-column prop="productname" label="产品名称" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="productype" label="产品类型" align="center"></el-table-column>
            <el-table-column prop="planon" label="计划时间" align="center"></el-table-column>
            <el-table-column prop="endon" label="结束时间" align="center"></el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <div class="Prod_right">
      <p class="Headline">领料计划</p>
      <div class="list">
        <el-table :data="tableDataq" stripe>
          <el-table-column prop type="index" label="序号" width="100px" align="center"></el-table-column>
          <el-table-column prop="pingkingon" label="领料时间" align="center"></el-table-column>
          <el-table-column prop="rawnumber" label="物料种类" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="states" label="状态" align="center"></el-table-column>
          <el-table-column prop label="操作人" align="center"></el-table-column>
          <el-table-column prop label="操作" align="center" width="160px">
            <template slot-scope="scope">
              <el-button size="small" type="warning" @click="pink(scope.row.pingkingno)">领料</el-button>
              <el-button type="primary" size="small" @click="pinkXiang(scope.row.pingkingno)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <el-dialog
      title="领料"
      :modal-append-to-body="false"
      :visible.sync="dialogVisiblepick"
      width="1000px"
    >
      <div class="color_box"></div>
      <div class="contents">
        <div class="accessories">
          <div class="f1">
            <el-form :model="form" class="demo-form-inline" label-width="130px">
              <el-form-item label="领料时间">
                <el-input v-model="form.pingkingno"></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div class="f1">
            <el-form :model="form" class="demo-form-inline" label-width="130px">
              <el-form-item label="领料产线">
                <el-input v-model="form.rawnumber"></el-input>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="accessories">
          <p class="Headline">生产计划</p>
          <el-table :data="tableDatapjh" :max-height="150" stripe>
            <el-table-column prop="text" type="index" label="序号" align="center"></el-table-column>
            <el-table-column prop="productname" label="产品名称" align="center"></el-table-column>
            <el-table-column prop="productype" label="产品类型" align="center"></el-table-column>
            <el-table-column prop="yuchang" label="预产量" align="center" show-overflow-tooltip></el-table-column>
          </el-table>
        </div>
        <div class="accessories">
          <p class="Headline">领料清单</p>
          <el-table :data="tableDatapqd" :max-height="150" stripe>
            <el-table-column prop="text" type="index" label="序号" align="center"></el-table-column>
            <el-table-column prop="rawname" label="物料名称" align="center"></el-table-column>
            <el-table-column prop="rawtype" label="物料类型" align="center"></el-table-column>
            <el-table-column prop="address" label="库存位置" align="center"></el-table-column>
            <el-table-column prop="inventory" label="库存数量" align="center"></el-table-column>
            <el-table-column prop="pinkingnumber" label="领料数量" align="center"></el-table-column>
          </el-table>
        </div>
        <div class="Btn">
          <el-button type="primary" @click="pinksure">确认</el-button>
          <el-button type="info" @click="dialogVisiblepick=false">取消</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      title="领料详情"
      :modal-append-to-body="false"
      :visible.sync="dialogVisiblepickXiang"
      width="1000px"
    >
      <div class="color_box"></div>
      <div class="contents">
        <div class="accessories">
          <div class="f1">
            <el-form :model="form" class="demo-form-inline" label-width="130px">
              <el-form-item label="领料时间">
                <el-input v-model="form.pingkingon"></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div class="f1">
            <el-form :model="form" class="demo-form-inline" label-width="130px">
              <el-form-item label="领料产线">
                <el-input v-model="form.rawnumber"></el-input>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="accessories">
          <p class="Headline">生产计划</p>
          <el-table :data="tableDatajh" :max-height="150" stripe>
            <el-table-column prop="text" type="index" label="序号" align="center"></el-table-column>
            <el-table-column prop="productname" label="产品名称" align="center"></el-table-column>
            <el-table-column prop="productype" label="产品类型" align="center"></el-table-column>
            <el-table-column prop="yuchang" label="预产量" align="center" show-overflow-tooltip></el-table-column>
          </el-table>
        </div>
        <div class="accessories">
          <p class="Headline">领料清单</p>
          <el-table :data="tableDataqd" :max-height="150" stripe>
            <el-table-column prop="text" type="index" label="序号" align="center"></el-table-column>
            <el-table-column prop="rawname" label="物料名称" align="center"></el-table-column>
            <el-table-column prop="rawtype" label="物料类型" align="center"></el-table-column>
            <el-table-column prop="address" label="库存位置" align="center"></el-table-column>
            <el-table-column prop="inventory" label="库存数量" align="center"></el-table-column>
            <el-table-column prop="pinkingnumber" label="领料数量" align="center"></el-table-column>
          </el-table>
        </div>
        <div class="Btn">
          <!-- <el-button type="primary">确认</el-button> -->
          <el-button type="info" @click="dialogVisiblepickXiang=false">取消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import daohanganniu from "../../components/daoHangAnNiu.vue";
export default {
  data() {
    return {
      form: {},
      tableData: [],
      tableDataqd: [],
      tableDatajh: [],
      tableDataq: [],
      tableDatapjh: [],
      tableDatapqd: [],
      tableDataonmonth: [],
      dialogVisiblepick: false,
      dialogVisiblepickXiang: false,
      pinkingno: "",
      a: ""
    };
  },
  created() {
    this.newMOnth();
    this.getpinklist();
    this.getAllmoney();
  },
  methods: {
    // 上月总工资
    getAllmoney() {
      axios("/apis/ProductionManagement.asmx/HP?index=1").then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log("上月总工资");
        console.log(datas);
        var list = JSON.parse(datas.string.__text);
        console.log(list);
      });
    },
    // 本月生产计划
    newMOnth() {
      axios("/apis/ProductionManagement.asmx/HP?index=3").then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log("本月生产计划");
        console.log(datas);
        var list = JSON.parse(datas.string.__text);
        console.log(list);
        this.tableDataonmonth = list;
        for (var i = 0; i < list.length; i++) {
          var dd = new Date(parseInt(list[i].planon.substr(6, 13)));
          var y = dd.getFullYear();
          var m = dd.getMonth() + 1;
          m = m < 10 ? "0" + m : m;
          var d = dd.getDate();
          d = d < 10 ? "0" + d : d;
          list[i].planon = y + "-" + m + "-" + d + " ";
          var dd = new Date(parseInt(list[i].endon.substr(6, 13)));
          var y = dd.getFullYear();
          var m = dd.getMonth() + 1;
          m = m < 10 ? "0" + m : m;
          var d = dd.getDate();
          d = d < 10 ? "0" + d : d;
          list[i].endon = y + "-" + m + "-" + d + " ";
        }
      });
    },
    // 领料计划列表
    getpinklist() {
      axios("/apis/ProductionManagement.asmx/HP?index=4").then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log("领料计划列表");
        console.log(datas);
        var list = JSON.parse(datas.string.__text);
        console.log(list);
        this.tableDataq = list;
        for (var i = 0; i < list.length; i++) {
          var dd = new Date(parseInt(list[i].pingkingon.substr(6, 13)));
          var y = dd.getFullYear();
          var m = dd.getMonth() + 1;
          m = m < 10 ? "0" + m : m;
          var d = dd.getDate();
          d = d < 10 ? "0" + d : d;
          list[i].pingkingon = y + "-" + m + "-" + d + " ";
        }
      });
    },
    // 详情
    pinkXiang(a) {
      this.dialogVisiblepickXiang = true;
      console.log(a);
      axios("/apis/ProductionManagement.asmx/Det?index=10&jsondata=" + a).then(
        ({ data }) => {
          var datas = this.$x2js.xml2js(data);
          console.log("领料");
          console.log(datas);
          var list = JSON.parse(datas.string.__text);
          console.log(list);
          this.tableDataqd = list.raws;
          this.tableDatajh = list.plan;
          this.form = list.mes;
        }
      );
    },
    // 领料
    pink(a) {
      this.dialogVisiblepick = true;
      console.log(a);
      axios("/apis/ProductionManagement.asmx/Det?index=10&jsondata=" + a).then(
        ({ data }) => {
          var datas = this.$x2js.xml2js(data);
          console.log("领料");
          console.log(datas);
          var list = JSON.parse(datas.string.__text);
          console.log(list);
          this.tableDatapqd = list.raws;
          this.tableDatapjh = list.plan;
          this.form = list.mes;
        }
      );
    },
    // 领料确认
    pinksure() {
      var obj = {
        pingkingno: ""
      };
      var objs = JSON.stringify(obj);
      axios("apis/ProductionManagement.asmx/Save?index=1&jsondata=订单号").then(
        ({ data }) => {
          var datas = this.$x2js.xml2js(data);
          if (datas.string.__text == "SUCCESS") {
            this.$message.success("领料成功!");
            this.dialogVisiblepick = false;
          } else {
            this.$message.error(datas.string.__text);
          }
        }
      );
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
.ProductionHmPg {
  width: 98%;
  margin-top: 20px;
  margin-left: 20px;
}
.Prod_left {
  width: 46%;
  display: inline-block;
}
.Prod_right {
  width: 53%;
  border: 1px solid $linecolor;
  background-color: white;
  float: right;
  border-radius: 5px;
  min-height: 600px;
}
.left_Up {
  width: 99%;
  height: 180px;
  // border: 1px solid $linecolor;
}
.left_down {
  margin-top: 20px;
  width: 99%;
  // height: 200px;
  border-radius: 5px;
  background-color: white;
  border: 1px solid $linecolor;
  min-height: 400px;
  // border: 1px solid #000;
}
.Headline {
  height: 40px;
  line-height: 40px;
  // font-weight: 700;
  color: $fontcolor;
  padding-left: 15px;
  border-bottom: 1px solid $linecolor;
}
.left_left {
  width: 48%;
  height: 100%;
  border-radius: 5px;
  border: 1px solid $linecolor;
  display: inline-block;
  background-color: white;
}
.left_right {
  float: right;
  width: 48%;
  height: 100%;
  border-radius: 5px;
  background-color: white;
  border: 1px solid $linecolor;
}
.f1 {
  width: 30%;
  display: inline-block;
}
.contents {
  // height: 600px;
  // height: 100%;
}
.accMessage {
  width: 35%;
  height: 50px;
  // border: 1px solid #000;
  display: inline-block;
  margin-left: 10px;
}
.accessories {
  // border: 1px solid #000;
}
.wb {
  width: 80%;
  // float: right;
}
.Btn {
  text-align: center;
  margin-top: 5px;
  // border: 1px solid #000;
}
.color_box {
  width: 5px;
  height: 20px;
  background-color: $Header_color;
  position: absolute;
  top: 22px;
  left: 10px;
}
.dd1 {
  width: 80%;
  margin: 0 auto;
  text-align: center;
  margin-top: 25px;
  // border: 1px solid #000;
}
.sp11 {
  font-size: 24px;
  font-weight: 700;
  font-style: normal;
  color: $red;
  // border: 1px solid #000;
}
.tp2s {
  height: 65px;
  overflow: hidden;
}
.ll1 {
  float: left;
  width: 32%;
  padding-top: 10px;
  height: 55px;
  margin-top: 10px;
  border-right: 1px solid $linecolor;
  text-align: center;
  // border: 1px solid #000;
}
.ll1 div {
  font-size: 10px;
}
.d1 {
  // font-weight: 700;
  font-size: 10px;
}
.rr1 {
  border: 0px;
}
.tp2 {
  margin-top: 30px;
  margin-right: 33px;
  float: right;
  font-size: 14px;
  // border: 1px solid #000;
}
.progress {
  width: 99%;
  margin-top: 15px;
  // border: 1px solid #000;
}
.progresscq {
  width: 21%;
  padding-left: 10px;
  display: inline-block;
  min-width: 66px;
  font-size: 10px;
}
.progresspeople {
  width: 13%;
  float: right;
  font-size: 10px;
  // border: 1px solid #000;
}
.pro {
  width: 55%;
  display: inline-block;
  // border: 1px solid #000;
}
</style>